home *** CD-ROM | disk | FTP | other *** search
/ Clickx 115 / Clickx 115.iso / software / tools / windows / tails-i386-0.16.iso / live / filesystem.squashfs / usr / share / system-config-printer / installdriver.py < prev    next >
Encoding:
Python Source  |  2010-09-28  |  2.5 KB  |  61 lines

  1. #!/usr/bin/env python
  2.  
  3. ## system-config-printer
  4.  
  5. ## Copyright (C) 2010 Red Hat, Inc.
  6. ## Author: Tim Waugh <twaugh@redhat.com>
  7.  
  8. ## This program is free software; you can redistribute it and/or modify
  9. ## it under the terms of the GNU General Public License as published by
  10. ## the Free Software Foundation; either version 2 of the License, or
  11. ## (at your option) any later version.
  12.  
  13. ## This program is distributed in the hope that it will be useful,
  14. ## but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16. ## GNU General Public License for more details.
  17.  
  18. ## You should have received a copy of the GNU General Public License
  19. ## along with this program; if not, write to the Free Software
  20. ## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  21.  
  22. import dbus
  23. import dbus.glib
  24. import dbus.service
  25.  
  26. class PrinterDriversInstaller(dbus.service.Object):
  27.     DBUS_PATH  = "/com/redhat/PrinterDriversInstaller"
  28.     DBUS_IFACE = "com.redhat.PrinterDriversInstaller"
  29.     DBUS_OBJ   = "com.redhat.PrinterDriversInstaller"
  30.  
  31.     def __init__ (self, bus):
  32.         self.bus = bus
  33.         bus_name = dbus.service.BusName (self.DBUS_OBJ, bus=bus)
  34.         dbus.service.Object.__init__ (self, bus_name, self.DBUS_PATH)
  35.  
  36.     @dbus.service.method(DBUS_IFACE,
  37.                          in_signature="sss",
  38.                          async_callbacks=("reply_handler",
  39.                                           "error_handler"))
  40.     def InstallDrivers (self, mfg, mdl, cmd,
  41.                        reply_handler, error_handler):
  42.         bus = dbus.SessionBus ()
  43.         obj = bus.get_object ("org.freedesktop.PackageKit",
  44.                               "/org/freedesktop/PackageKit")
  45.         proxy = dbus.Interface (obj, "org.freedesktop.PackageKit.Modify")
  46.         proxy.InstallPrinterDrivers (0, ["MFG:%s;MDL:%s;" % (mfg, mdl)],
  47.                                      "hide-finished",
  48.                                      reply_handler=reply_handler,
  49.                                      error_handler=error_handler,
  50.                                      timeout=3600)
  51.  
  52. if __name__ == "__main__":
  53.     bus = dbus.SystemBus ()
  54.     import sys
  55.     if len (sys.argv) < 2 or sys.argv[1] == "--client":
  56.         # Client
  57.         obj = bus.get_object (PrinterDriversInstaller.DBUS_OBJ,
  58.                               PrinterDriversInstaller.DBUS_PATH)
  59.         proxy = dbus.Interface (obj, PrinterDriversInstaller.DBUS_IFACE)
  60.         print proxy.InstallDrivers ("MFG", "MDL", "CMD")
  61.